﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sparkle.MVVM.Messages
{
    public class SendMessage : ISendMessage
    {
        public string MessageName { get; set; }
        public object AttachedObject { get; set; }

        public SendMessage(string message)
        {
            MessageName = message;
        }

        public SendMessage(string message, object attachedObject)
            :this(message)
        {
            AttachedObject = attachedObject;
        }
        public object Send()
        {
            var results = new List<object>();
            Defaults.Messages.Where(x => x.Key == MessageName)
                .ToList().ForEach(x => results.Add(
                    x.Value.Process(x.Value.AssosiatedObject,
                    MessageName,
                    AttachedObject)));

            return results;
        }
    }

}
